//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for SMS
public struct SMSErrorType: AWSErrorType {
    enum Code: String {
        case dryRunOperationException = "DryRunOperationException"
        case internalError = "InternalError"
        case invalidParameterException = "InvalidParameterException"
        case missingRequiredParameterException = "MissingRequiredParameterException"
        case noConnectorsAvailableException = "NoConnectorsAvailableException"
        case operationNotPermittedException = "OperationNotPermittedException"
        case replicationJobAlreadyExistsException = "ReplicationJobAlreadyExistsException"
        case replicationJobNotFoundException = "ReplicationJobNotFoundException"
        case replicationRunLimitExceededException = "ReplicationRunLimitExceededException"
        case serverCannotBeReplicatedException = "ServerCannotBeReplicatedException"
        case temporarilyUnavailableException = "TemporarilyUnavailableException"
        case unauthorizedOperationException = "UnauthorizedOperationException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize SMS
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// The user has the required permissions, so the request would have succeeded, but a dry run was performed.
    public static var dryRunOperationException: Self { .init(.dryRunOperationException) }
    /// An internal error occurred.
    public static var internalError: Self { .init(.internalError) }
    /// A specified parameter is not valid.
    public static var invalidParameterException: Self { .init(.invalidParameterException) }
    /// A required parameter is missing.
    public static var missingRequiredParameterException: Self { .init(.missingRequiredParameterException) }
    /// There are no connectors available.
    public static var noConnectorsAvailableException: Self { .init(.noConnectorsAvailableException) }
    /// This operation is not allowed.
    public static var operationNotPermittedException: Self { .init(.operationNotPermittedException) }
    /// The specified replication job already exists.
    public static var replicationJobAlreadyExistsException: Self { .init(.replicationJobAlreadyExistsException) }
    /// The specified replication job does not exist.
    public static var replicationJobNotFoundException: Self { .init(.replicationJobNotFoundException) }
    /// You have exceeded the number of on-demand replication runs you can request in a 24-hour period.
    public static var replicationRunLimitExceededException: Self { .init(.replicationRunLimitExceededException) }
    /// The specified server cannot be replicated.
    public static var serverCannotBeReplicatedException: Self { .init(.serverCannotBeReplicatedException) }
    /// The service is temporarily unavailable.
    public static var temporarilyUnavailableException: Self { .init(.temporarilyUnavailableException) }
    /// You lack permissions needed to perform this operation. Check your IAM policies, and ensure that you are using the correct access keys.
    public static var unauthorizedOperationException: Self { .init(.unauthorizedOperationException) }
}

extension SMSErrorType: Equatable {
    public static func == (lhs: SMSErrorType, rhs: SMSErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension SMSErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
